<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>球桌管理</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.12"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css"
          integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <style>
        .action-btn{
            margin-right: 20px;
        }
    </style>
</head>
<body>
<div id="app">
    <ul id="myTab" class="nav nav-tabs">
        <template v-for = "num in 20">
            <li>
                <a v-bind:href= "('#' + num)" data-toggle="tab">{{num}}号桌</a>
            </li>
        </template>
    </ul>

    <div id="myTabContent" class="tab-content">
        <template v-for="(table, index) in table_info">
            <div class="tab-pane fade in" :id="(index + 1)">
                <h3 style="text-align: center;">{{index + 1}}号球桌当前比赛</h3>
                <br>
                <table class="table table-hover table-bordered">
                  <thead>
                    <tr>
                        <th>场次</th>
                        <th>选手A</th>
                        <th>选手B</th>
<!--                        <th>操作</th>-->
                    </tr>
                  </thead>
                  <tbody>
                    <tr v-for="(item, index) in table">
                      <td>{{index + 1}}</td>
                      <td>{{item['a_username']}} （{{item['a_id']}}号）</td>
                      <td>{{item['b_username']}} （{{item['b_id']}}号）</td>
<!--                      <td>-->
<!--                        <button type="button" class="btn btn-primary action-btn">A 获胜</button>-->
<!--                        <button type="button" class="btn btn-default action-btn">B 获胜</button>-->
<!--                        <button type="button" class="btn btn-default action-btn">双方弃权</button>-->
<!--                      </td>-->
                    </tr>
                  </tbody>
                </table>
            </div>
        </template>

    </div>

</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"
        integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
        crossorigin="anonymous"></script>

<script type="text/javascript">
    var vm = new Vue({
        el: '#app',
        data: {
            table_info: []
        },
        methods: {
            //获取台桌比赛信息
            getTableInfo: function (){
                let that = this;
                axios.get("/start/getAllTableInfo.php")
                            .then(function (response){
                                 that.table_info = response.data;
                            })
            }
        }
    })

    vm.getTableInfo();
</script>

</html>
